<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title></title>
<link rel="stylesheet" href="lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
</head>
<body class="pos-r">
<script th:src="@{/js/vue-2.4.0.js}"></script>
<script th:src="@{/js/vue-resource-1.3.4.js}"></script>
<div class="pos-a" style="width:300px;left:0;top:0; bottom:0; height:100%; border-right:1px solid #e5e5e5; background-color:#f5f5f5; overflow:auto;">
	<ul id="treeDemo" class="ztree"></ul>
</div>
<div style="margin-left:300px;" id="app">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 管理 <span class="c-gray en">&gt;</span> 用户管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="cl pd-5 bg-1 bk-gray mt-20">
    <span class="l">
			<a href="javascript:;" onclick="user_add('添加用户','user-add','800','500')" class="btn btn-primary radius"><i class="icon-plus"></i> 添加用户</a>
			<a href="javascript:;" onclick="deleteItems()" class="btn btn-danger radius"><i class="icon-trash"></i> 删除</a>
			<a href="javascript:;" @click="setjurisdiction()" class="btn radius"><i class="icon-trash"></i> 设置角色</a>
			<a href="javascript:;" onclick="stateItems()" class="btn radius"><i class="icon-trash"></i> 禁用/启用</a>
			<a href="javascript:;" onclick="reset_pwd('重置密码','reset-pwd','300','200')" class="btn radius"><i class="icon-trash"></i> 重置密码</a>
		</span>
    <!-- <span class="r">共有数据：<strong>88</strong> 条</span> -->
  </div >
    <div class="mt-20">
        <form name="itemsForm" action="/delUser" method="post">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr>
                <th scope="col" colspan="10">用户管理</th>
            </tr>
            <tr class="text-c">
                <th width="25"><input type="checkbox" name="" value=""></th>
                <th width="80">用户ID</th>
                <th width="100">姓名</th>
                <th width="70">角色</th>
                <th width="150">所属部门</th>
                <th width="150">岗位</th>
                <th width="50">状态</th>
                <th width="150">人员资质</th>
                <th width="150">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr  v-for="item in UserList" class="text-c va-m">
                <td><input type="checkbox" @click="resetshow(item.users.id)" name="items_id" :value="item.users.id"></td>
                <td>{{item.users.name}}</td>
                <td>{{item.users.xname}}</td>
                <td>{{item.rolename}}</td>
                <td>{{item.departmentname}}</td>
                <td>{{item.users.jobs}}</td>
                <td class="user-status"><span class="label label-success" v-if="item.users.state==0">
                 <span >正常</span>
                </span>
                <span class="label label-error" v-if="item.users.state==1">
                    <span >禁用</span>
                    </span>
                </td>
                <td>{{item.users.qualification}}</td>
                <td><a href="javascript:;" @click="Show_edit(item.users.id)" class="btn radius">编辑用户</a></td>
                </tr>
            </tbody>
        </table>
        </form>
    </div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">

var setting = {
	view: {
		dblClickExpand: false,
		showLine: false,
		selectedMulti: false
	},
	data: {
		simpleData: {
			enable:true,
			idKey: "id",
			pIdKey: "pId",
			rootPId: ""
		}
	},
	callback: {
        beforeClick: function(treeId, treeNode) {
            var zTree = $.fn.zTree.getZTreeObj("tree");
            if (treeNode.isParent) {
                vm.judgeShow(treeNode.id,0,0)
                zTree.expandNode(treeNode)
                return false;
            } else {
                //demoIframe.attr("src",treeNode.file + ".html");
                vm.judgeShow(0,treeNode.pdid,treeNode.pdid)
                return true;
            }
        }
	}
};
function user_add(title,url,w,h){
    var url1="/user-add?id="+vm.add
    vm.addskip(title,url1,w,h)
}
function user_edit(title,url,w,h){
	layer_show(title,url,w,h);
}

function reset_pwd(title,url,w,h){
    if(vm.reset!=0) {
        var urll = "/reset-pwd?id=" + vm.reset
        layer_show(title, urll, w, h);
    }else {
        layer.msg("请选择你要重置密码的用户!",{icon:7,time:1500})
    }
}

function deleteItems(){
    document.itemsForm.action="/delUser";
    document.itemsForm.submit();
}

function stateItems(){
    document.itemsForm.action="/stateUpl";
    document.itemsForm.submit();
}

function jurisdictionItems(title,url,w,h) {
    layer_show(title,url,w,h);
}

var vm=new Vue({
    el:'#app',
    data:{
        UserList:[],
        Departments:[],
        Maxdepartments:[],
        zNodes:[],
        add:0,
        reset:0
    },
    created() {
        this.zNodes=[{id:-1,pId:0,name:"全部",open:true}]
        this.User_Show()
        this.Showzb()
        this.Showtree()
        this.User_Show(-1,0)
    },
    methods:{
        User_Show(id,pdid){
            this.$http.get("/UserShow", {
                params: {
                    id:id,
                    pdid:pdid
                }
            }).then(function (result) {
                this.UserList=result.data
            })
        },
        Showzb(){
            this.$http.get("/Selzgeneral", {
                params: {
                }
            }).then(function (result) {
                this.Maxdepartments=result.data
                for (var i=0;i<this.Maxdepartments.length;i++){
                    var car = {id:this.Maxdepartments[i].sId, pId:-1, name:this.Maxdepartments[i].sumdepartment}
                    this.zNodes.push(car)
                }
                var t = $("#treeDemo");
                t = $.fn.zTree.init(t, setting, this.zNodes);
                var zTree = $.fn.zTree.getZTreeObj("tree");
            })
        },
        Showtree(){
            this.$http.get("/Seldepartment", {
                params: {
                }
            }).then(function (result) {
               this.Departments=result.data;

                for (var j=0;j<this.Departments.length;j++){
                    var car = {id:j+5, pId:this.Departments[j].department.maxd_id, name:this.Departments[j].department.name,pdid:this.Departments[j].department.id}
                    this.zNodes.push(car)
                }
                var t = $("#treeDemo");
                t = $.fn.zTree.init(t, setting, this.zNodes);
                var zTree = $.fn.zTree.getZTreeObj("tree");
                // location.reload()
            })
        },
        judgeShow(id,pdid,addid){
            this.add=addid
            this.User_Show(id,pdid)
        },
        addskip(title,url1,w,h){
             if(this.add!=0){
                 layer_show(title,url1,w,h);
             }else {
                 layer.msg("请选择部门添加用户!",{icon:7,time:1500})
             }

        },
        resetshow(id){
            this.reset=id
        },
        Show_edit(id){
            var url="/user-edit?id="+id
            user_edit("用户编辑",url,800,500)
        },
        setjurisdiction(){
            if (this.reset!=0){
                var url="user_role?id="+this.reset;
                jurisdictionItems("角色设置",url,500,300)
            }else {
                layer.msg("请选择用户设置角色!",{icon:7,time:1500})
            }
         }

    }
})



setTimeout(function () {
    $('.table-sort').dataTable({
        "bStateSave": true,//状态保存
        "aoColumnDefs": [
            {"orderable":false,"aTargets":[0,1,2,3,4,5,6,7]},// 制定列不参与排序

        ]
    });
},100)
</script>
</body>
</html>